package com.birdpiss.commons.domain;

/**
 * The Enum TransactionStatus.
 *
 * @author mark
 */
public enum TransactionStatus {

	PENDING(0),
	NEEDS_AUTHORIZATION(1),
	AUTHORIZED(2),
	SETTLED(3);

	private Integer value;

	/**
	 * Instantiates a new transaction status.
	 *
	 * @param value the value
	 */
	private TransactionStatus(Integer value) {
		this.value = value;
	}

	/**
	 * Value.
	 *
	 * @return the integer
	 */
	public Integer value() {
		return this.value;
	}

	/**
	 * Gets the transaction status.
	 *
	 * @param transactionStatus the transaction status
	 *
	 * @return the transaction status
	 */
	public static TransactionStatus getTransactionStatus(Integer transactionStatus) {
		switch (transactionStatus) {
			case 0:
				return PENDING;
			case 1:
				return NEEDS_AUTHORIZATION;
			case 2:
				return AUTHORIZED;
			case 3:
				return SETTLED;
			default:
				return null;
		}
	}

	/**
	 * To string.
	 *
	 * @param transactionStatus the transaction status
	 *
	 * @return the string
	 */
	public static String toString(Integer transactionStatus) {
		switch (transactionStatus) {
			case 0:
				return "PENDING";
			case 1:
				return "NEEDS_AUTHORIZATION";
			case 2:
				return "AUTHORIZED";
			case 3:
				return "SETTLED";
			default:
				return "NULL";
		}
	}

}
